<template>
	<div class="container" style="padding-top: 50px;">
		<div>
			<div class="alert alert-info"><h2>{{$store.state.user.uname}}的个人中心</h2></div>
			<router-link to="/center/orderList" style="font-size: 19px;">查看我的订单</router-link>
			<router-view/>
			<div class="input-control has-icon-left" style="margin-bottom: 10px; margin-top: 10px;">
				<input style="width: 100%;" id="inputAccountExample1" type="text" class="form-control" placeholder="用户号" v-model="uidModel" />
				<label for="inputAccountExample1" class="input-control-icon-left"><i class="icon icon-user "></i></label>
			</div>
			<div class="input-control has-icon-left" style="margin-bottom: 10px;">
				<input style="width: 100%;" id="inputAccountExample1" type="text" class="form-control" placeholder="用户名" v-model="unameModel" />
				<label for="inputAccountExample1" class="input-control-icon-left"><i class="icon icon-user "></i></label>
			</div>
			<div class="input-control has-icon-left" style="margin-bottom: 10px;">
				<input style="width: 100%;" id="inputEmailExample1" type="text" class="form-control" placeholder="密码" v-model="upwdModel" />
				<label for="inputEmailExample1" class="input-control-icon-left"><i class="icon icon-envelope "></i></label>
				<label for="inputEmailExample1" class="input-control-icon-right"><i class="icon icon-check"></i></label>
			</div>
			<div class="input-control has-icon-left" style="margin-bottom: 10px;">
				<input style="width: 100%;" id="inputAccountExample1" type="text" class="form-control" placeholder="性别" v-model="usexModel" />
				<label for="inputAccountExample1" class="input-control-icon-left"><i class="icon icon-user "></i></label>
			</div>
			<button class="btn btn-primary" type="button" @click="onUpdate">修改</button>
			&nbsp;&nbsp;
			<button class="btn btn-primary" type="button" @click="back">返回</button>
		</div>
	</div>
</template>

<script>
export default {
	name: 'regist',
	data() {
		return {
			unameModel: this.$store.state.user.uname,
			upwdModel: this.$store.state.user.upwd,
			uidModel: this.$store.state.user.uid,
			usexModel: this.$store.state.user.usex,
			errorText: '',	
			flag: this.$store.state.loginFlag
		};
	},
	computed: {
		
	},
	methods: {
		onUpdate() {
			const config={
				method: 'post',
				url: 'http://localhost:8080/json/user/update',
				data: {
				uname: this.unameModel,
				upwd: this.upwdModel,
				uid: this.uidModel,
				usex: this.usexModel
				}
			}
			
			this.$axios(config).then(result => {
				if(result.data==true){
					alert("修改成功!")
					this.$router.push("/")
				}else{
					alert("修改失败!")
				}
			})
		},
		back(){
			this.$router.push('/');
		},
		toOrder(){
			this.$router.push('/center/orderList');
		}
	}
};
</script>

<style>
.input-radio {
	font-size: 15px;
	color: #777;
}
</style>
